package com.letou.ls.view;


import com.letou.ls.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
import android.widget.TextView;


public class SelectButton extends RelativeLayout {
    private TextView iv_select;
    private TextView tv_name;

    private Boolean isEnable = true;
    private Boolean isSelect;
    
    public SelectButton(Context context) {
        this(context, null);
    }

    public SelectButton(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SelectButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        LayoutInflater inflater = LayoutInflater.from(getContext());
        RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.view_select_button, this);
        iv_select = (TextView) view.findViewById(R.id.iv_select);

        tv_name = (TextView) view.findViewById(R.id.tv_name);
    }


    public Boolean getIsEnable() {
        return isEnable;
    }

    public void setIsEnable(Boolean isEnable) {
        this.isEnable = isEnable;
        if (isEnable) {
            iv_select.setBackgroundResource(R.drawable.dot_withe);
        } else {
            iv_select.setBackgroundResource(R.drawable.dot_grey);
        }
    }

    public void setSelectButton(Boolean isSelect) {
        this.isSelect = isSelect;
        if (isSelect) {
            iv_select.setBackgroundResource(R.drawable.dot_black);
        } else {
            iv_select.setBackgroundResource(R.drawable.dot_withe);
        }
    }

    public Boolean isSelectButton() {
        return isSelect;
    }

    public void setText(String msg) {
        tv_name.setText(msg);
    }
}
